﻿using System;
using System.Collections.Generic;
using System.Text;
using Org.Eurekaa.DNJ.Settings;
using System.ComponentModel;

namespace Org.Eurekaa.DNJ.UI.DNJSettings
{

    [TypeConverter(typeof(ExpandableObjectConverter))]
    [Serializable()]

    public class DNJDialogEvents : GenericSettingsObject
    {
        //[Description("")]
        //[DefaultValue(""), NotifyParentProperty(true), RefreshProperties(RefreshProperties.Repaint)]
        //[PersistenceMode(PersistenceMode.InnerProperty), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        //public UIEventFunction Change
        //{
        //    get { return Get<UIEventFunction>("change"); }
        //    set { this["change"] = value; }
        //}


        public DNJDialogEvents()
        {
//            this["search"] = new UIEventFunction();

        }

        public string GetDefaultEventsScript()
        {
            String evtScript = String.Empty;
            foreach (UIEventFunction evt in Settings.Values)
            {
                if (!string.IsNullOrEmpty(evt.Name))
                {
                    evtScript += "if (!window." + evt.Name.Trim() + "){" + evt.Name.Trim() + " = new Function(\"return dnjDefaultEvent('" + evt.Name.Trim() + "')\");}";
                }
            }

            return evtScript;
        }

    }
}
